/**
 * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
 * @param {number[]} nums
 * @return {number}
 */
 var removeDuplicates = function(nums) {
    if (nums.length < 2) return nums.length;
    let count = 0;
    let i = 0;
    while(i < nums.length) {
        if (i === 0 || nums[i] !== nums[i - 1]) {
            nums[count] = nums[i];
            count++;
        }
        i++;
    }
    return count;
};